<?php 
namespace Admin\Controller;

class NewsController extends AdminController
{
    public function index()
    {
        //查询经验表
        $co = M('comment');

        $count = $co->count();// 查询满足要求的总记录数
        $Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show = $Page->show();// 分页显示输出
        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $comment = $co->limit($Page->firstRow.','.$Page->listRows)->select();
        //查询评论表
        $experience = M('experience')->select();


        $this->assign('page',$show);// 赋值分页输出
        $this->assign('experience',$experience);
        $this->assign('comment',$comment);
        $this->display('News/index');
    }

    //删除操作
    public function del()
    {
        $id = $_POST['id'];
        M('comment')->create();
        M('comment')->delete($id);
        $this->ajaxReturn();
    }
}
 ?>